var app = angular.module('myApp')
  .controller('btnController',['$scope','$state','$location',function($scope,$state,$location){
  	
		var lis = document.querySelectorAll('.btn');
    var a = document.querySelectorAll('ul>a');
    
    $scope.fn = function(num){
    	for(var i=0;i<lis.length;i++){
			lis[i].index = i;
			lis[i].style.background = '';
			a[i].style.color = '#777';
		}
		if(num != 0){
			lis[0].style.background = 'url(./index/img/ic_tabbar_home_normal.png) no-repeat center 0.1rem';
			lis[0].style.backgroundSize = 'auto 0.5rem';
		}
		a[num].style.color = '#ffd600';
		lis[num].style.background = 'url(./index/img/' + num + '.png) no-repeat center 0.1rem';
		lis[num].style.backgroundSize = 'auto 0.5rem';	
	  }

 		if($location.path() == '/comic'){
//			console.log(lis);
			$scope.fn(0);
		}else if($location.path() == '/find'){
			$scope.fn(1);
		}else if($location.path() == '/public/public1' || $location.path() == '/public/public2' ){
			$scope.fn(2);
		}else if($location.path() == '/mine'){
			$scope.fn(3);
		}
 }])
  .controller('navController',function($timeout){
  	$timeout(function () {
            $('#footer-nav-holder').fadeOut();
        },1000);
  })
  
$(function(){
	$(window).scroll(function(){
		var $scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
		if($scrollTop>300){
			$('#c-backtop').show();
		}else{
			$('#c-backtop').hide();
		}
	});
	$('#c-backtop').click(function(){
		$('html,body').animate({scrollTop:0},300);
		return false;
	})
})
